home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_1.3 / Read-Me1.3 / Printer1.3 / Driver.Examples / src / hp / transfer.c < prev   
Encoding:
C/C++ Source or Header  |  1988-08-01  |  1.9 KB  |  68 lines

  1. /*
  2.     Transfer routine for HP_LaserJet driver.
  3.     David Berezowski - October/87.
  4. */
  5.  
  6. #include <exec/types.h>
  7. #include "../printer/prtgfx.h"
  8.  
  9. Transfer(PInfo, y, ptr)
  10. struct PrtInfo *PInfo;
  11. UWORD y;    /* row # */
  12. UBYTE *ptr;    /* ptr to buffer */
  13. {
  14.     static UBYTE bit_table[] = {128, 64, 32, 16, 8, 4, 2, 1};
  15.     UBYTE *dmatrix, Black, dvalue, threshold;
  16.     union colorEntry *ColorInt;
  17.     UWORD x, width, sx, *sxptr, bit;
  18.  
  19.     /* pre-compute */
  20.     /* printer non-specific, MUST DO FOR EVERY PRINTER */
  21.     x = PInfo->pi_xpos; /* get starting x position */
  22.     ColorInt = PInfo->pi_ColorInt; /* get ptr to color intensities */
  23.     sxptr = PInfo->pi_ScaleX;
  24.     width = PInfo->pi_width; /* get # of source pixels */
  25.  
  26.     /* pre-compute threshold; are we thresholding? */
  27.     if (threshold = PInfo->pi_threshold) { /* thresholding */
  28.         dvalue = threshold ^ 15; /* yes, so pre-compute dither value */
  29.         do { /* for all source pixels */
  30.             /* pre-compute intensity value for Black */
  31.             Black = ColorInt->colorByte[PCMBLACK];
  32.             ColorInt++; /* bump ptr for next time */
  33.  
  34.             sx = *sxptr++;
  35.  
  36.             /* dither and render pixel */
  37.             do { /* use this pixel 'sx' times */
  38.                 /* if we should render Black */
  39.                 if (Black > dvalue) {
  40.                     /* set bit */
  41.                     *(ptr + (x >> 3)) |= bit_table[x & 7];
  42.                 }
  43.                 ++x; /* done 1 more printer pixel */
  44.             } while (--sx);
  45.         } while (--width);
  46.     }
  47.     else { /* not thresholding, pre-compute ptr to dither matrix */
  48.         dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  49.         do { /* for all source pixels */
  50.             /* pre-compute intensity value for Black */
  51.             Black = ColorInt->colorByte[PCMBLACK];
  52.             ColorInt++; /* bump ptr for next time */
  53.  
  54.             sx = *sxptr++;
  55.  
  56.             /* dither and render pixel */
  57.             do { /* use this pixel 'sx' times */
  58.                 /* if we should render Black */
  59.                 if (Black > dmatrix[x & 3]) {
  60.                     /* set bit */
  61.                     *(ptr + (x >> 3)) |= bit_table[x & 7];
  62.                 }
  63.                 ++x; /* done 1 more printer pixel */
  64.             } while (--sx);
  65.         } while (--width);
  66.     }
  67. }
  68.